import * as grpc from '@grpc/grpc-js';

import { TestService } from './gen/test_grpc_pb';
import { TestRes } from './gen/test_pb';


const server = new grpc.Server();


server.addService(TestService, {
    sayTest(call: any, callback: any) {
        console.log(call.request.getName());
        const res = new TestRes();
        res.setName("Test: " + call.request.getName());
        callback(null, res);
    }
});



server.bindAsync("localhost:3333", grpc.ServerCredentials.createInsecure(), () => {
    console.log('GRPC服务启动')
})